import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import get from '@dfeidao/atom-web/local/get';
import set from '@dfeidao/atom-web/local/set';
import render from '@dfeidao/atom-web/render/render';
import p007 from './p007';

export default async function a015(fd: IFeidaoAiBrowserComponent) {
	// todo
	const node_chk = fd.data.node.querySelectorAll('[data-id="list3"]:checked');
	// const arr = Array.from(node_chk);
	const list = Array.from(node_chk) as HTMLInputElement[];
	console.log(list);
	if (list.length === 0) {
		alert("请选择一条数据");
	} else {
		const l = list.map((v) => {
			return v.getAttribute('data-no');
		});
		console.log(l);
		const n = get(fd, 'data1') as Array<{ attr_no: string }>;
		const arr: Array<{ attr_no: string }> = [];
		n.forEach((e) => {
			const no = e.attr_no;
			const s = l.includes(no);
			if (!s) {
				arr.push(e);
			}
		});
		render(fd, arr, p007, 'p007', 'inner');
		set(fd, 'data1', arr);
	}
}
